<?php
include 'lang/en.php';
include 'core/filesize.php';
include 'core/user.php';
$version='MintOS-19-05-2013_22-22';
?>
<!DOCTYPE html>
<html lang="en">

<head>

	<!-- General Metas -->
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	<!-- Force Latest IE rendering engine -->
	<title>Login to MintOS</title>
	<meta name="description" content="">
	<meta name="author" content="">
	<!--[if lt IE 9]>
		<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
	
	<!-- Mobile Specific Metas -->
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> 
	
	<!-- Stylesheets -->
	<link rel="stylesheet" href="assets/css/login/base.css">
	<link rel="stylesheet" href="assets/css/login/skeleton.css">
	<link rel="stylesheet" href="assets/css/login/layout.css">
	
	<style>
	button {
		background: #eafaea;
		color: #0C1424;
		cursor: pointer;
		display: inline-block;
		font-size: 13px;
		font-weight: bold;
		padding: 5px 15px;
		position: relative;
		text-decoration: none;
		text-shadow: none;
		white-space: nowrap;
		-moz-border-radius: 5px;
		-webkit-border-radius: 5px;
		border-radius: 5px;
	}
	button:hover {
		background: #daeada;
		color: #0C1424;
		cursor: pointer;
		display: inline-block;
		font-size: 13px;
		font-weight: bold;
		padding: 5px 15px;
		position: relative;
		text-decoration: none;
		text-shadow: none;
		white-space: nowrap;
		-moz-border-radius: 5px;
		-webkit-border-radius: 5px;
		border-radius: 5px;
	}
	button:active {
		background: #cadaca;
		color: #0C1424;
		cursor: pointer;
		display: inline-block;
		font-size: 13px;
		font-weight: bold;
		padding: 5px 15px;
		position: relative;
		text-decoration: none;
		text-shadow: none;
		white-space: nowrap;
		-moz-border-radius: 5px;
		-webkit-border-radius: 5px;
		border-radius: 5px;
	}
	input[type="checkbox"] {
		box-shadow: 0px 0px 0px 4px #e0f1fc;
		border:1px solid #7dc6dd;
	}
	</style>
	
</head>
<?php
$error = false;
if(isset($_POST['login'])){
    $username = preg_replace('/[^A-Za-z]/', '', $_POST['username']);
    $password = md5($_POST['password']);
    if(file_exists('users/' . $username . '.xml')){
        chmod('users/'.$username.'.xml',0640);
        $xml = new SimpleXMLElement('users/' . $username . '.xml', 0, true);
        if($password == $xml->password){
            echo "password OK";
            session_start();
            $_SESSION['username'] = $username;
            $_SESSION['loggedin'] = true;
            chmod('users/'.$username.'.xml',0600);
            header('Location: index.php');
            die;
        }
    }
    $error = true;
}
?>
<body>

	<?php if ($error) echo '
	<div class="notice">
		<a href="" class="close">close</a>
		<p class="warn">Whoops! We didn\'t recognise your username or password. Please try again.</p>
	</div>';
	?>

	<div class="container">
		<div class="form-bg">
			<form action="" method="POST">
				<img src="core/logo-HQ.png">
				<p><input type="text" name="username" placeholder="Username"></p>
				<p><input type="password" name="password" placeholder="Password"></p>
				<label for="remember">
				  <input type="checkbox" id="remember" value="remember" />
				  <span>Remember me on this computer</span>
				</label>
				<button type="submit"  value="Login" name="login" >Login</button>
		</form>
		</div>


	</div><!-- container -->

	<!-- JS  -->
	<script src="assets/js/jquery.js"></script>
	<script>window.jQuery || document.write("<script src='js/jquery-1.5.1.min.js'>\x3C/script>")</script>
	<script src="js/app.js"></script>
	
<!-- End Document -->
</body>
</html>